﻿using System;
using System.Windows.Input;

using Perseus;

namespace Hetymine.Executioner.Commands {
    public class HotKeyInfo {
        public HotKeyInfo() { }
        public HotKeyInfo(string hotkey) {
            string[] parts = hotkey.Split(                
                "+",
                SplitOptions.Trim | SplitOptions.RemoveEmptyEntries
            );

            this.Modifiers = ModifierKeys.None;

            foreach (string s in parts) {
                //if (s.ToLower() == "win") {
                //    this.Modifiers |= ModifierKeys.Windows;
                //    continue;
                //}

                if (s.ToLower() == "alt") {
                    this.Modifiers |= ModifierKeys.Alt;
                    continue;
                }

                if (s.ToLower() == "ctrl") {
                    this.Modifiers |= ModifierKeys.Control;
                    continue;
                }

                if (s.ToLower() == "shift") {
                    this.Modifiers |= ModifierKeys.Shift;
                    continue;
                }

                this.Key = (Key)Enum.Parse(typeof(Key), s);
            }
        }
        public HotKeyInfo(Key key, ModifierKeys modifiers) {
            this.Key = key;
            this.Modifiers = modifiers;
        }

        public Key Key { get; set; }
        public ModifierKeys Modifiers { get; set; }

        /// <summary>
        /// Set to hotkey's global atom when registered.
        /// </summary>
        internal ushort Id { get; set; }        
        /// <summary>
        /// Only need to register hotkey once even if multiple 
        /// commands use the same one.
        /// </summary>
        internal bool Registered { get; set; }
    }
}
